<?php
namespace services;
use Sanyc\Aliyun\AliyunEmail;

class MailAliyun implements SmsInterface
{
    private $config = '';

    public function __construct ($config = array())
    {
        $mail_config = config('mail');
        $mail_config = array_merge($mail_config, $config);
        $this->config = $mail_config;
    }
    /**
     * 发送验证码
     * @param  string $mail        邮箱
     * @param  numeric  $code      验证码
     * @param  int $active_time    有效时间
     * @return bool                true/false
     */
    public function sendCaptcha ($mail, $code, $active_time)
    {
        $bodys = lang('captcha_body',['code' => $code,'active_time' => $active_time]);
        if (true == AliyunEmail::init($this->config)->send($mail, lang('site_name'), $bodys)) {
            return true;
        }
        return false;
    }
    /**
     * 发送订单信息
     * @param  [type] $mail [description]
     * @param  [type] $body [description]
     * @return [type]       [description]
     */
    public function sendOrder ($mail, $body)
    {
        return true;
    }
    /**
     * 发送信息
     * @param  [type] $mail [description]
     * @param  [type] $body [description]
     * @return [type]       [description]
     */
    public function sendMessage($mail, $body)
    {
        # code...
    }
    public function sendSearch($mail, $body)
    {
        if (AliyunEmail::init($this->config)->send($mail, lang('site_name'), $body)) {
            return true;
        }
        return false;
    }
    public function sendJm($body, $mail = '')
    {
        if (AliyunEmail::init($this->config)->send($mail, '加盟咨询', $body)) {
            return true;
        }
        return false;
    }
}